package org.lq.rbac.web;

import org.lq.rbac.vo.MenuVO;

import java.io.Serializable;
import java.util.List;

public class HttpResult<T> implements Serializable {

    private Integer code;//响应码,1表示OK,0表示出错 ： 前段根据这个响应码做适当的逻辑处理
    private String  message;//响应消息,OK时这里有消息
    private String error;//出错时这里有消息
    private T data;//数据


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static final Integer OK=1;
    public static final Integer ERROR=0;

    private HttpResult(T data,Integer code,String message){
        this.data=data;
        this.code=code;
        this.message=message;

    }

    public static <DATA> HttpResult ok(DATA data,String message) {

        HttpResult<DATA> result = new HttpResult<>(data,HttpResult.OK,message);

        return result;

    }
    public static <DATA> HttpResult error(DATA data,String message) {

        HttpResult<DATA> result = new HttpResult<>(data,HttpResult.ERROR,message);

        return result;

    }




}
